package com.derbysoft.ota.interfaces.ws.generic;

import com.derbysoft.ota.application.service.CancelService;
import com.derbysoft.ota.application.service.StagingService;
import com.derbysoft.ota.domain.server.ServerType;
import com.derbysoft.ota.interfaces.protocol._2009a.OTACancelRQ;
import com.derbysoft.ota.interfaces.ws.AbstractEndpoint;

public class CancelEndpoint extends AbstractEndpoint {

	private CancelService cancelService;

	public CancelEndpoint(ServerType serverType, StagingService stagingService, CancelService cancelService) {
		super(serverType, stagingService);
		this.cancelService = cancelService;
	}

	@Override
	protected Object invokeInternal(Object requestObject) throws Exception {
		if (serverType.isStaging()) {
			return stagingService.cancel((OTACancelRQ) requestObject);
		}
		return cancelService.make((OTACancelRQ) requestObject);
	}

}
